package com.rpcfx.server;

import com.rpcfx.DefaultRegistryCenterServiceImpl;
import com.rpcfx.api.RegistryCenterService;
import com.rpcfx.transports.NettyHttpServer;

public class Server {

    public static int port = 20881;

    public static String connectingStr = "127.0.0.1:2181";

    private static NettyHttpServer httpServer;

    private static RegistryCenterService registryCenterService;

    public static void start() {
        registryCenterService = new DefaultRegistryCenterServiceImpl(connectingStr, port);
        httpServer = new NettyHttpServer(registryCenterService);
        new Thread(() -> {
            try {

                httpServer.start(port);


            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }

    public static boolean registry(Class<?> clazz) {
        return registryCenterService.registry(clazz);
    }
}
